package com.lianyu507.controller;


import com.lianyu507.task.CrawlerTask;
import com.lianyu507.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/testCrawler")
public class CrawlerController extends BaseController {

    @Autowired
    private CrawlerTask crawlerTask;
    @RequestMapping("/crawler")
    @ResponseBody
    public JSONResult testCrawler(){
        JSONResult result = new JSONResult();
        if (crawlerTask.crawArticle()){
            result.setSuccess(false);
            result.setMsg("insert crawler data failed,exits in database already");
        }
        else{
            result.setSuccess(true);
            result.setMsg("insert crawler data success");
        }
        return result;
    }
}
